
import java.util.ArrayList;
import java.util.Iterator;

import java.util.List;
import java.util.ListIterator;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 * Date: 2024-01-04
 * Time: 20:58
 */
public class Test2 {
    public static void main(String[] args) {
        ArrayList<Integer> arrayList = new ArrayList<>();
        arrayList.add(1);
        arrayList.add(2);
        arrayList.add(3);
        arrayList.add(2, 10);
        System.out.println(arrayList);
        for (int x : arrayList) {
            System.out.print(x + " ");
        }
        System.out.println();
        for (int i = 0; i < arrayList.size(); i++) {
            System.out.print(arrayList.get(i) + " ");
        }
        System.out.println();
        System.out.println("====================");
     /*   Iterator<Integer> it1=arrayList.iterator();
        while (it1.hasNext()){
            System.out.print(it1.next()+" ");
        }
        System.out.println();
        System.out.println("===================");
        ListIterator<Integer> it2=arrayList.listIterator();
        while (it2.hasNext()){
            System.out.print(it2.next()+" ");
        }
        System.out.println();
        System.out.println("===================");
    }*/
      //  Iterator<Integer> it2 = arrayList.iterator(arrayList.size());
        ListIterator<Integer> iterator=arrayList.listIterator(arrayList.size());
        while (iterator.hasPrevious()){
            System.out.print(iterator.previous()+" ");
        }
    }
}